package com.wz.service.impl;

import com.domain.User;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.wz.dao.UserDao;
import com.wz.service.UserService;
import org.apache.dubbo.config.annotation.Service;
import org.springframework.beans.factory.annotation.Autowired;

import java.util.List;

/*@Service*/
@Service
public class UserServiceImpl implements UserService {

    @Autowired
    private UserDao userDao;


    @Override
    public boolean register(User user) {
           return userDao.save(user) == 1; //如果添加成功,那么就返回true
    }

    @Override
    public PageInfo pageQuery(Integer page, Integer size) {
        PageHelper.startPage(page, size);
        List list = userDao.findAll();//返回实现类是Page
        return new PageInfo(list);
    }

    @Override
    public boolean update(User user) {
        int result = userDao.update(user);
        return result==1;
    }

    @Override
    public User findByUuid(Integer uuid) {
        User user = userDao.get(uuid);
        return user;
    }

    @Override
    public int deleteByUuid(Integer uuid) {
        int result = userDao.delete(uuid);
        return result;
    }


}
